﻿using System.ComponentModel;
using CuteRibs.MVVMLib;
using CuteRibs.WowArmory.Resources;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace CuteRibs.WowArmory.Views
{
	public class PageBase : ViewBase
	{
		private static AppRes appRes = new AppRes();

		public PageBase()
			: base()
		{
			this.Orientation = PageOrientation.Portrait;

			this.Loaded += delegate
			{
				if (!App.IsDesignMode)
				{
					SystemTray.IsVisible = false;

					if (this.ApplicationBar != null)
					{
						this.ApplicationBar.Opacity = 0.7d;
					}
				}
			};
		}

		protected override void SetTransition()
		{
			var element = this;
			var inTransition = new NavigationInTransition
			{
				Forward = new SlideTransition { Mode = SlideTransitionMode.SlideLeftFadeIn },
				Backward = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeIn }
			};

			var outTransition = new NavigationOutTransition
			{
				Forward = new SlideTransition { Mode = SlideTransitionMode.SlideLeftFadeOut },
				Backward = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeOut }
			};

			TransitionService.SetNavigationInTransition(element, inTransition);
			TransitionService.SetNavigationOutTransition(element, outTransition);
		}

		protected override void OnBackKeyPress(CancelEventArgs e)
		{
			base.OnBackKeyPress(e);

			if (this.ViewModel.ShowProgressBar)
			{
				this.ViewModel.ShowProgressBar = false;
			}
		}
	}
}
